import pygame, sys, os
from pygame.locals import *

def parse_webcolor (name):
	return (int(name[1:3],16), int(name[3:5],16), int(name[5:7],16))


def load_image(name,key=None):
	""" Load image and return image object"""
	fullname = os.path.join('data', name)
	try:
		image = pygame.image.load(fullname)
		if image.get_alpha() is None:
			image = image.convert()
		else:
			image = image.convert_alpha()
		if key is not None:
			image.set_colorkey(key)
	except pygame.error, message:
        	print 'Cannot load image:', fullname
        	raise SystemExit, message
	return image, image.get_rect()

